package ppt

import (
	"context"

	v1 "web-ppt/api/ppt/v1"

	"github.com/gogf/gf/v2/frame/g"
)

func (c *ControllerV1) Show(ctx context.Context, req *v1.ShowReq) (res *v1.ShowRes, err error) {
	r, count, err := c.ppt.Show(ctx, req.Id, req.Page)
	content := r[0]["content"].String()

	dianjigongnen, err := c.ppt.ListDianji(ctx)

	page := c.view.Page(ctx, count, 1)

	c.view.RenderTpl(ctx, "ppt/show.html", g.Map{
		"content":       content,
		"page":          page,
		"dianjigongnen": dianjigongnen,
	})

	return nil, err
}
